package org.example.objevent.process.login;

import org.example.business.endpoint.http.event.message.HttpMsg;
import org.example.objevent.process.Process;
import org.example.objevent.process.login.data.LoginData;

public class HttpLoginProcess extends Process {

    private HttpMsg httpMsg;
    private LoginProcess loginProcess;

    @Override
    public boolean accept(Object data) {

        if(!(data instanceof HttpMsg)){
            return false;

        }

        HttpMsg httpMsg = (HttpMsg)data;

        if(!"/login".equalsIgnoreCase(httpMsg.getHttpReq().getPath())){
            return false;

        }

        return true;

    }

    @Override
    public void start() {

        // 解析http请求，获取登录数据
        LoginData loginData = new LoginData();

        loginData.setUsername(httpMsg.getHttpReq().getParam("username"));
        loginData.setPassword(httpMsg.getHttpReq().getParam("username"));

        loginProcess.start();


    }

}
